function [draw accept log_density prior] = MR_EEA75d(x0,VARCOV,logd_x0,prior_x0)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This is part of the set of files that accompany the article:       %
%Mankiw, N. Gregory and Ricardo Reis (2007) "Sticky Information in  %
%General Equilibrium," Journal of the European Economic Association,%
%forthcoming. See the appendix of the NBER or CEPR working paper    %
%versions for a detailed explanation of the algorithms.             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Please cite if you use the programs. I do not provide tech support.%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Last revised: August 30, 2006                                      %
%Written by: Ricardo Reis                                           %
%Input: x0 and VARCOV are mean and variance of proposal function,   %
%       logd_x0 and prior_x0 its log-likelihood and prior prob      %
%Output: draw is new draw, accept is 0-1 if acceptance or not,      %
%        log-density is the log-lik value, and prior the prior prob %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global T K N Y pars_c

%%%%% STEP 1: NEW DRAW %%%%%%
candidate = mvnrnd(x0,VARCOV);
prior_candidate = SIGEprior(candidate);

%%%%% STEP 2: METROPOLIS ACCEPTANCE %%%%%%
draw=x0; accept=0; log_density=logd_x0; prior=prior_x0; %baseline is reject
if prior_candidate~=0
    ldc=SIGEloglik(candidate);   %this is the numerically costly step
    r = exp(ldc-logd_x0)*(prior_candidate/prior_x0);
    U=rand;
    if U<r;
        draw=candidate; accept=1; log_density=ldc; prior=prior_candidate;
    end %only accept here
end
